/*
  Created by 1271107612@qq.com.
  User: DELL
  Date: 2022/4/9
  Time: 13:14
  DESCRIPTION: 
*/
package com.zzy.face.utils.jwt;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {

    /**
     * 添加jwt拦截器，并指定拦截路径
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor0())
                .addPathPatterns("/student/**");
        registry.addInterceptor(jwtInterceptor1())
                .addPathPatterns("/teacher/**");
        registry.addInterceptor(jwtInterceptor2())
                .addPathPatterns("/admin/**");
        registry.addInterceptor(jwtInterceptor0())
                .addPathPatterns("/rl/**");
    }

    /**
     * jwt拦截器
     */
    @Bean
    public JwtInterceptor jwtInterceptor0() {
        Jwt jwt = new Jwt();
        return new JwtInterceptor(jwt,0);
    }

    @Bean
    public JwtInterceptor jwtInterceptor1() {
        Jwt jwt = new Jwt();
        return new JwtInterceptor(jwt,1);
    }

    @Bean
    public JwtInterceptor jwtInterceptor2() {
        Jwt jwt = new Jwt();
        return new JwtInterceptor(jwt,2);
    }
}

